<template>
	<view class="shootGame">
    <canvas canvas-id="main" style="width:400px;height:400px" @touchmove="onMove" @touchstart="onStart" @touchend="onEnd" @tap="onTap"></canvas>
    <!--button @click="shoot">点击1</button>
    <button @click="enemy">生产1</button-->
    <view @click="left">左</view>
    <view @click="right">右</view>
    <view @click="start">开始</view>
	</view>
</template>
<script>
import * as Main from '@/game/class/main.js'
import * as Stage from '@/game/class/stage.js'
import * as Player from '@/game/class/player.js'
import * as Enemy from '@/game/class/enemy.js'
import store from '@/game/store/index.js'
export default {
  data() {
    return {
      title: 'Hello'
    }
  },
  mounted() {
    Main.init();
    this.stage = Stage.init();
    this.player = Player.init();
    this.enemy = Enemy.init();
  },
  methods: {
    shoot(){
      this.player.shoot();
    },
    enemy(){
      this.enemy.produce();
    },
    left(){
      this.player.left();
    },
    right(){
      this.player.right();
    },
    start(){
      this.stage.start();
    },
    onMove(e){
      store.state.main.dom.fire('touchMove',e);
    },
    onTap(e){
      store.state.main.dom.fire('tap',e);
    },
    onStart(e){
      store.state.main.dom.fire('touchStart',e);
    },
    onEnd(e){
      store.state.main.dom.fire('touchEnd',e);
    },
  }
}
</script>

<style>
</style>
